package com.cungmua.app.model.request;

import com.cungmua.app.model.User;
import com.cungmua.app.utils.AppUtils;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonUnwrapped;

import java.text.DateFormat;
import java.text.SimpleDateFormat;

/**
 * Created by kelvin.nguyen on 7/1/14.
 */
public class EditProfileRequest extends AuthenticatedRequest {
    private int userId;
    private User user;

    public EditProfileRequest(String deviceId, String token) {
        super(deviceId, token);
    }

    @JsonProperty("UserId")
    public int getUserId() {
        return userId;
    }

    public void setUserId(int userId) {
        this.userId = userId;
    }

    @JsonUnwrapped
    public User getUser() {
        return user;
    }

    public void setUser(User user) {
        this.user = user;
    }

    @Override
    public String getSign() {
        DateFormat format = new SimpleDateFormat("MM/dd/yyyy");
        return AppUtils.MD5(String.valueOf(getUserId()) + user.getName() + user.getMobile() +
                format.format(user.getDateOfBirth()) + user.getGender() + getVersion() + getDeviceId() + getToken());
    }
}
